﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A2DFramework.LogService
{
    public class ExceptionWrapper
    {
        public ExceptionWrapper()
        { 
        }

        public ExceptionWrapper(Exception ex)
        {
            this.OccurredOn = DateTime.Now;
            this.Message = ex.Message;
            this.Source = ex.Source;
            this.StackTrace = ex.StackTrace;
            if (ex.TargetSite!=null)
                this.TargetSite = ex.TargetSite.ToString();
            if(ex.InnerException!=null)
            {
                this.InnerMessage = ex.InnerException.Message;
                this.InnerSource = ex.InnerException.Source;
                this.InnerStackTrace = ex.InnerException.StackTrace;
                if (ex.InnerException.TargetSite!=null)
                    this.InnerTargetSite = ex.InnerException.TargetSite.ToString();
            }
        }

        public string Ip { get; set; }
        public DateTime OccurredOn { get; set; }

        public string Message { get; set; }
        public string Source { get; set; }
        public string StackTrace { get; set; }
        public string TargetSite { get; set; }
        public string InnerMessage { get; set; }
        public string InnerSource { get; set; }
        public string InnerStackTrace { get; set; }
        public string InnerTargetSite { get; set; }

        public List<string> AdditionalInfos { get; set; }
    }
}
